
function parseArgs(key){
	args = window.location.href.split('?')[1]
	allArgs = args.split('&')
	for(i in allArgs){
		vK = allArgs[i].split('=')
		if(vK[0] == key){
			return vK[1]	
		}
	}
	return ''
}

function randomStr(len) {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = len;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

function specialToSafe(cString)
{
//use this in the future encodeURI()
//use this in the future dencodeURI()
//	encodeURIComponent() for special characters
	//return Base64.encode(cString)


	if(cString == null) return cString
	if(cString == undefined) return cString


	cString = cString.replace(/'/g, "|===|")
	cString = cString.replace(/&/g, "|amps|")
	cString = cString.replace(/#/g, "|pnd|")
	cString = cString.replace(/@/g, "|at|")
	cString = cString.replace(/%/g, "|pcnt|")
	cString = cString.replace(/\(/g, "|lbr|")
	cString = cString.replace(/\)/g, "|rbr|")
	cString = cString.replace(/\*/g, "|star|")
	cString = cString.replace(/\[/g, "|lbra|")
	cString = cString.replace(/\]/g, "|rbra|")
	cString = cString.replace(/\?/g, "|qst|")
	cString = cString.replace(/\:/g, "|col|")
	cString = cString.replace(/\;/g, "|scol|")
	cString = cString.replace(/\,/g, "|com|")
	cString = cString.replace(/\{/g, "|lcbr|")
	cString = cString.replace(/\}/g, "|rcbr|")
	cString = cString.replace(/\"/g, "|dqu|")
	//cString = cString.replace(/\//g, '|slash|')

	return cString
}

function SafeStringToSpecial(cString)
{
	if(cString == null) return cString
	if(cString == undefined) return cString

	//return Base64.decode(cString)

	cString = cString.replace(/\|===\|/g,"'")
	cString = cString.replace(/\|amps\|/g,   "&") 
	cString = cString.replace(/\|pnd\|/g,    "#") 
	cString = cString.replace(/\|at\|/g,     "@") 
	cString = cString.replace(/\|pcnt\|/g,   "%") 
	cString = cString.replace(/\|lbr\|/g,   "(") 
	cString = cString.replace(/\|rbr\|/g,   ")") 
	cString = cString.replace(/\|star\|/g,   "*") 
	cString = cString.replace(/\|lbra\|/g,   "[") 
	cString = cString.replace(/\|rbra\|/g,   "]") 
	cString = cString.replace(/\|qst\|/g,   "?") 
	cString = cString.replace(/\|col\|/g,   ":") 
	cString = cString.replace(/\|scol\|/g,   ";") 
	cString = cString.replace(/\|com\|/g,   ",") 
	cString = cString.replace(/\|lcbr\|/g,   "{") 
	cString = cString.replace(/\|rcbr\|/g,   "}") 
	cString = cString.replace(/\|dqu\|/g,   "\"") 
	cString = cString.replace(/\%20/g,   " ") 
	//cString = cString.replace('|slash|', '/')
	return cString
}

